package org.jeecg.modules.charge.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.entity.basedata.BaseTenant;
import org.jeecg.entity.charge.ChargeBills;
import org.jeecg.entity.charge.ChargeFeeitem;
import org.jeecg.entity.charge.ChargeInvoiceRequest;
import org.jeecg.model.charge.reqvo.DayReportReqVo;
import org.jeecg.model.charge.resvo.DayReportRespVo;
import org.jeecg.modules.charge.entity.ChargeBillsOrder;

import java.util.Date;
import java.util.List;

/**
 * @Description: 订单表
 * @Author: jeecg-boot
 * @Date: 2019-08-15
 * @Version: V1.0
 */
public interface ChargeBillsOrderMapper extends BaseMapper<ChargeBillsOrder> {

    @SqlParser(filter = true)
    ChargeBillsOrder getOrderBySn(@Param("sn") String sn);

    //支付回到 结束更新对应的状态
    @SqlParser(filter = true)
    public Integer updatePayStatus(@Param("sn") String sn, @Param("response") String response, @Param("paytime") String paytime, @Param("tradeNo") String tradeNo);

    //前端销账接口。
    @SqlParser(filter = true)
    public Integer updateBillsByIds(@Param("billIds") List<String> billIds,
                                    @Param("skrq") String skrq,
                                    @Param("method") String method,
                                    @Param("userId") String userId,
                                    @Param("orderId") String orderId,
                                    @Param("updateByTime") Date updateByTime);

    //多表分页查询
    List<ChargeBillsOrder> listByProject(@Param("page") Page<ChargeBillsOrder> page, @Param("billsOrder")ChargeBillsOrder billsOrder);

    //根据订单号获取对应的订单信息
    public ChargeBillsOrder getOrder(@Param("sn") String sn);
    //插入对应的发票请求表中
    public Integer insertInvoiceReq(@Param("deail") ChargeInvoiceRequest deail);
    //获取房间ID
    public String getRoomIdByCid(@Param("cid") String cid);
    //更新账单
    public Integer updateBillsInvoice(ChargeBills bills);

    //根据房间ID和收费项目代号获取对应项目的税率
    public Integer getRateByRoomFeeCode(@Param("roomid") String roomid, @Param("feecode") String feecode);
    //根据代号获取对应的收费项目
    public ChargeFeeitem getFeeByCode(@Param("fcode") String fcode);
    //根据会计科目编号获取对应的会计科目名称
    public String  getSubNameByCode(@Param("subcode") String subcode);
    @Select("SELECT floor_id FROM base_customer WHERE id = #{cid} AND del_flag = '0'")
    String getfloorIdByCid(@Param("cid") String cid);

    @Select("SELECT * FROM base_tenant WHERE id = #{id} AND del_flag = '0'")
    BaseTenant getBaseTenantById(@Param("id") String id);

    public void updateInvoiceReq(@Param("statusInv") String statusInv,@Param("urlReq") String urlReq,@Param("remarks") String remarks,@Param("fpqqlsh") String fpqqlsh);

    public List<DayReportRespVo> findGroupList(@Param("dayReportReqVo") DayReportReqVo dayReportReqVo);

    String getFeeNameByOrderId(@Param("orderId") String orderId,@Param("refundStatus") Integer refundStatus, @Param("type") int type);

    List<ChargeInvoiceRequest> invoiceRequestListBySn(@Param("sn") String sn);

    ChargeInvoiceRequest invoiceRequestByFpqqlsh(@Param("fpqqlsh") String fpqqlsh);

    @Select("update charge_invoice_request set del_flag = '1' where fpqqlsh = #{fpqqlsh}")
    public void deleteInvoiceReq(@Param("fpqqlsh") String fpqqlsh);

//    @Select("select * from charge_feeitem where id = #{id}")
//    ChargeFeeitem getByFeeItemId(String id);
}
